package net.borlis.sample.services.facade.ws.response.util;

import net.borlis.dictionaries.product.HierarchyLevelDictionary;
import net.borlis.dictionaries.product.LifecycleStateDictionary;
import net.borlis.sample.service.entities.configuration.interfaces.ICreditCardDetailEntity;
import net.borlis.sample.service.entities.configuration.interfaces.ITravelPeriodEntity;
import net.borlis.sample.service.entities.configuration.parents.VitoEntity;
import net.borlis.sample.service.entities.general.*;
import net.borlis.sample.service.entities.history.*;
import net.borlis.sample.service.entities.lifecycle.Lifecycle;
import net.borlis.sample.services.facade.ws.request.HistoryFilterView;
import net.borlis.sample.services.facade.ws.request.TravelDurationRequest;
import net.borlis.sample.services.facade.ws.response.*;
import net.borlis.sample.services.output.*;
import net.borlis.scheduler.lifecycle.UploadStatus;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * The interface for a translator between data entities and UI view beans.
 *
 * @author alex@borlis.net
 */
public interface IBuilderViewData {

    /**
     * Converts Dynamic Locale response by service tier entity
     *
     * @param locale - {@link net.borlis.sample.service.entities.general.DynamixLocaleEntity}
     * @return - {@link net.borlis.sample.services.facade.ws.response.DynamixLocaleResponse}
     */
    DynamixLocaleResponse createDynamixLocaleViewData(DynamixLocaleEntity locale);

    ProviderResponse createProviderViewData(DynamixProviderDetailEntity providerDetail);

    /**
     * Converts service tier entities {@link net.borlis.sample.service.entities.general.CountryDetailEntity} and
     * {@link net.borlis.sample.service.entities.general.CurrencyDetailEntity} to view tier response
     * {@link net.borlis.sample.services.facade.ws.response.CountryResponse}
     *
     * @param countryDetail  - {@link net.borlis.sample.service.entities.general.CountryDetailEntity} country entity
     * @param currencyDetail - {@link net.borlis.sample.service.entities.general.CurrencyDetailEntity} currency entity
     * @return - {@link net.borlis.sample.services.facade.ws.response.CountryResponse}
     */
    CountryResponse createCountryViewData(CountryDetailEntity countryDetail, CurrencyDetailEntity currencyDetail);

    /**
     * Converts localized VITO entity from MW service tier to view bean
     *
     * @param vitoLocalized - {@link net.borlis.sample.services.output.VitoFilteredLocalized}
     * @return - {@link net.borlis.sample.services.facade.ws.response.VitoResponse}
     */
    VitoResponse createVitoViewData(VitoFilteredLocalized vitoLocalized);

    /**
     * Converts localized VITO entity from MW service tier to view bean with providers
     *
     * @param vitoLocalized - {@link net.borlis.sample.services.output.VitoFilteredLocalized}
     * @return - {@link net.borlis.sample.services.facade.ws.response.VitoWithProvidersResponse}
     */
    VitoWithProvidersResponse createVitoWithProvidersViewData(VitoFilteredLocalized vitoLocalized);

    /**
     * Converts service tier provider with provider details localized to view tier bean
     *
     * @param providerLocalized - {@link net.borlis.sample.services.output.ProviderLocalized}
     * @return - {@link net.borlis.sample.services.facade.ws.response.ProviderResponse}
     */
    ProviderResponse createProviderViewData(ProviderLocalized providerLocalized);

    /**
     * Converts {@link java.util.List} of MW service tier beans to {@link java.util.Map} of MW view tier beans bounded
     * with its history (ex. CREATED, UPLOADED, RESTORED .. etc.)
     *
     * @param lifecycleList - list of {@link net.borlis.sample.service.entities.lifecycle.Lifecycle}
     * @return - map of {@link net.borlis.sample.service.entities.lifecycle.LifecycleState} bounded on
     * {@link net.borlis.sample.services.facade.ws.response.LifecycleEventResponse}
     */
    Map<LifecycleStateDictionary, GetLifecycleStateResponse> createLifeCycleConfigurationsViewData(List<Lifecycle> lifecycleList);

    ProviderWithVitoResponse createProviderWithVitoViewData(ProviderConfigured providerConfigured);

    /**
     * Converts localized filter {@link net.borlis.sample.services.output.FilterLocalized
     * to VITO plus VITO provider with details view tier response bean
     *
     * @param filterLocalized - {@link net.borlis.sample.services.output.FilterLocalized}
     * @return - {@link net.borlis.sample.services.facade.ws.response.VitoFilterResponse}}
     */
    VitoFilterResponse createVitoFilterViewData(FilterLocalized filterLocalized);

    List<BaseCountryResponse> createBaseCountryViewDataList(List<CountryDetailEntity> countryDetails);

    BaseCountryResponse createBaseCountryViewData(CountryDetailEntity countryDetail);

    /**
     * Converts {@link java.util.List} of {@link net.borlis.sample.service.entities.configuration.parents.VitoEntity} service tier
     * entities to a {@link java.util.List} of {@link net.borlis.sample.services.facade.ws.response.BaseVitoResponse}
     *
     * @param vitoList - List of {@link net.borlis.sample.service.entities.configuration.parents.VitoEntity}
     * @return - List of {@link net.borlis.sample.services.facade.ws.response.BaseVitoResponse}
     */
    List<BaseVitoResponse> createBaseVitoViewDataList(List<VitoEntity> vitoList);

    /**
     * Converts MW service tier VITO configuration upload status {@link net.borlis.sample.service.entities.lifecycle.LifecycleStatus}
     * to view tier response {@link net.borlis.sample.services.facade.ws.response.UploadStatusResponse}
     *
     * @param us - {@link net.borlis.scheduler.lifecycle.UploadStatus}
     * @return - {@link net.borlis.sample.services.facade.ws.response.UploadStatusResponse}
     */
    UploadStatusResponse createUploadStatusViewData(UploadStatus us);

    /**
     * Method that map HTTP-Request data to Service-tier HistoryFilter to search in History on DB side
     *
     * @param request - Mapped http json request
     * @param vitoId  - Virtual tour operator identifier
     * @param userId  - User that invoked history search
     * @param locale  - User's locale to represent data
     * @return {@link net.borlis.sample.service.entities.history.HistoryFilter} - HistoryFilter
     */
    HistoryFilter createHistoryFilterByRequest(HistoryFilterView request, Long vitoId, Long userId, String locale);

    /**
     * Method maps Service-tier response for the history search to View Bean
     *
     * @param historyResultFiltered list of {@link net.borlis.sample.services.output.HistoryResultFiltered}
     * @return {@link net.borlis.sample.services.facade.ws.response.GetHistoryResponseContainer} list as mapped
     */
    GetHistoryResponseContainer createHistoryResponse(HistoryResultFiltered historyResultFiltered);

    /**
     * Convert service bean to view bean
     *
     * @param elements {@link net.borlis.sample.service.entities.history.HistoryElement} field names
     * @param locale   - locale for translation
     * @return list of {@link net.borlis.sample.services.facade.ws.response.FilterGetResultTypeResponse} result view beans
     */
    FilterGetResultTypeResponse createGetResultTypeResponse(List<HistoryElement> elements, String locale);

    /**
     * @param tp - {@link net.borlis.sample.services.output.TravelPeriodLocalized} bean to create
     * @return - {@link net.borlis.sample.services.facade.ws.response.TravelPeriodResponse} response view bean
     */
    TravelPeriodResponse createTravelPeriodViewData(TravelPeriodLocalized tp);

    /**
     * converts MW-side response into the VIEW bean
     *
     * @param historyViewResultResponse {@link net.borlis.sample.service.entities.history.HistoryViewResultResponse}
     * @return {@link net.borlis.sample.services.facade.ws.response.GetHistoryResponseContainer}
     */
    GetHistoryResponseContainer buildHistorySearchResponse(HistoryViewResultResponse historyViewResultResponse);

    /**
     * converts MW-tier types - {@link net.borlis.sample.service.entities.history.DpctMenu} to view bean
     *
     * @param menuItems {@link java.util.List} of {@link net.borlis.sample.service.entities.history.DpctMenu}
     * @return {@link java.util.List} of {@link net.borlis.sample.services.facade.ws.response.IdLabelResponse}
     */
    List<IdLabelResponse> buildMenuItemsResponse(Collection<DpctMenu> menuItems, String localeCode);

    /**
     * converts MW-tier history filter to filter view bean
     *
     * @param historyFilter - {@link net.borlis.sample.service.entities.history.HistoryFilter}
     * @return - {@link net.borlis.sample.services.facade.ws.request.HistoryFilterView}
     */
    HistoryFilterView buildViewFilterForLifecycleConfiguration(HistoryFilter historyFilter);

    List<IdLabelResponse> buildActionTypes(List<HistoryActionType> actionTypes);

    List<IdLabelResponse> createElementTypes(List<HistoryElementType> historyElementTypes, String locale);

    Set<IdLabelResponse> createResultTypes(List<HistoryElement> historyElements, String locale);

    List<TravelDurationEntity> createTravelDurations(List<TravelDurationRequest> travelDurationBeanList);

    List<TravelPeriodResponse> createTravelPeriodViewData(List<ITravelPeriodEntity> travelPeriods);

    VitoAddressResponse createVitoAddressViewData(VitoAddressLocalized va);

    List<VitoAddressResponse> createVitoAddressViewData(List<VitoAddressLocalized> vitoAddresses);

     //-=-=-
    List<BankAccountResponse> createBankAccountViewData(List<BankDetailLocalized> bankDetails);

    BankAccountResponse createBankAccountViewData(BankDetailLocalized bankDetail);

    CreditCardDetailResponse createCreditCardViewData(ICreditCardDetailEntity creditCardDetail);

    List<CreditCardDetailResponse> createCreditCardViewData(List<ICreditCardDetailEntity> creditCardDetail);

    CreditCardTypeResponse createCreditCardTypeViewData(CreditCardTypeEntity cct);
    // -=-=-

    ProviderBookingInfoResponse createProviderBookingInfoViewData(ProviderBookingInfoLocalized info);

    List<ProviderBookingInfoResponse> createProviderBookingInfoViewData(List<ProviderBookingInfoLocalized> infoList);

    List<BookingConfigResponse> createBookingConfigViewData(List<BookingConfigLocalized> bookingConfigs);

    BookingConfigResponse createBookingConfigViewData(BookingConfigLocalized bookingConfig);

    BookingConfigStrategyResponse createBookingConfigStrategyViewData(BookingConfigStrategyEntity bcs);

    PortfolioSettingResponse createPortfolioSettingViewData(PortfolioSettingLocalized ps);

    List<TravelDurationResponse> createTravelDurationsViewData(List<TravelDurationLocalized> travelDurations);

    HierarchyLevelResponse createHierarchyLevelViewData(HierarchyLevelDictionary hierarchyLevelEnumValue, String hierarchyLevelName);
}
